/**
 * Created by yangjiao on 2019/7/29.
 */
import ElementUI from 'element-ui'
import { cloneDeep } from 'lodash'
import { pickerBeforeDestroy, tabsBarSyle1, computePresentText } from '@/utils/elementModify' // element内存泄漏
// element tabs组件barStyle样式修改
ElementUI.Tabs.components.TabNav.components.TabBar.computed.barStyle.get = tabsBarSyle1
console.log(ElementUI.Cascader.methods)
ElementUI.Cascader.methods.computePresentText = computePresentText
// TimePicker TimeSelect DatePicker 销毁时销毁this.picker实例。（解决内存泄漏问题）
ElementUI.TimePicker.beforeDestroy = pickerBeforeDestroy
ElementUI.TimeSelect.beforeDestroy = pickerBeforeDestroy
ElementUI.DatePicker.beforeDestroy = pickerBeforeDestroy
// menu-item 删除时没有更新 activeIndex修复
ElementUI.Menu.methods.removeItem = function removeItem (item) {
  this.$delete(this.items, item.index)
}
let NoTransitionTree = ElementUI.Tree
try {
  NoTransitionTree = cloneDeep(ElementUI.Tree)
  NoTransitionTree.components.ElTreeNode.components.ElCollapseTransition.render = function (createElement, vm) {
    return createElement(
      'div',
      vm.children
    )
  }
  NoTransitionTree.name += 'NoTransition'
} catch (e) {
  console.log('el-tree-no-transition: ', e)
}
export { NoTransitionTree, ElementUI }
